/*
 * =====================================================================================
 *
 *       Filename:  cl_cond_mutex.cxx
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  12/11/2010 11:10:33 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Chen Ken (Ken), zlchen.ken@gmail.com
 *        Company:  EMC
 *
 * =====================================================================================
 */

#include <unistd.h>
#include "cl_cond_mutex.hxx"

namespace neo
{

CLCondMutex::CLCondMutex() 
{
  pthread_condattr_init(&m_condAttr);
  pthread_cond_init(&m_cond, &m_condAttr);
}

CLCondMutex::~CLCondMutex() 
{
  pthread_cond_destroy(&m_cond);
  pthread_condattr_destroy(&m_condAttr);
}

bool CLCondMutex::wait(void) 
{
  int rval = pthread_cond_wait(&m_cond, getMutex());
  return (rval == 0); 
}

bool CLCondMutex::notify(void) 
{
  int rval = pthread_cond_signal(&m_cond);
  return (rval == 0);
}

bool CLCondMutex::broadcastNotify(void) 
{
  int rval = pthread_cond_broadcast(&m_cond);
  return (rval == 0);
}

} // neo
